from tkinter import *
from backend import *

window = Tk()

def run_backend():
    file_path = e.get()
    if file_path.strip() == "":
        label_text.set("请输入文件地址!")
    else:
        count_result = multi_thread_stat(file_path)
        if count_result:
            label_text.set("%s个python文件，%s行python代码"%(count_result['file_count'],count_result['total_code_line']))
        else:
            label_text.set("找不到该文件地址！")

window.title("统计")

window.geometry('360x120')

label_text = StringVar()
label_text.set("x个python文件，x行python代码")
result_label = Label(window,textvariable=label_text,font=('Arial',11))
result_label.pack_configure(padx=0,pady=10,side='top')

w = Label(window,text="请输入指定的目录：")
w.pack_configure(padx=5,pady=10,side='left')

e = Entry(window, bd =5)
e.pack_configure(padx=5,pady=10,side='left')

b = Button(window, text="运行", command=run_backend)
b.pack_configure(padx=5,pady=20,side='left')



window.mainloop()